package office.dao.finance;

import platform.common.dao.impl.BaseDomainProviderImpl;

public class NoteDP extends BaseDomainProviderImpl{

	/**
	 * 获取某用户的票据
	 * @return
	 */
	public String getFindById(){
		return "select new office.action.finance.form.NoteForm(a.id,a.noteType," +
				"a.noteDate,a.remark,a.userId,a.entryRole,a.checkRole,a.entryDate," +
				"a.state,b.name) from "+this.getDomainClassName()+" a,User b where a.id=:id and a.userId = b.id";
	}
	
	/**
	 * 获取某用户提交的或需要自己审批的票据
	 * @return
	 */
	public String getFindByUserIdCheckRole(){
		return "select new office.action.finance.form.NoteForm(a.id,a.noteType," +
				"a.noteDate,a.remark,a.userId,a.entryRole,a.checkRole,a.entryDate," +
				"a.state,b.name) from "+this.getDomainClassName()+" a,User b where " +
				"(a.userId=:userId or checkRole =:checkRole) and a.userId = b.id  order by a.entryDate desc";
	}
	/**
	 * 获取某用户提交的或需要自己审批的票据(销售人员、区域经理、销售经理需要限制是和自己同一部门人提交审批的记录)
	 * @return
	 */
	public String getFindByUserIdCheckRoleDept(){
		return "select new office.action.finance.form.NoteForm(a.id,a.noteType," +
				"a.noteDate,a.remark,a.userId,a.entryRole,a.checkRole,a.entryDate," +
				"a.state,b.name) from "+this.getDomainClassName()+" a,User b where " +
				"(a.userId=:userId or checkRole =:checkRole) and a.userId = b.id  and b.department.id in (:deptId) order by a.entryDate desc";
	}
}
